package com.example.grpcserver.server;

import com.example.grpclib.GreeterGrpc;
import com.example.grpclib.HelloReply;
import com.example.grpclib.HelloReplyOrBuilder;
import com.example.grpclib.HelloRequest;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
import net.devh.springboot.autoconfigure.grpc.server.GrpcService;

/**
 * @Author 赵云龙
 * @Date 2020/6/20
 * @Description TODO
 */
@Slf4j
@GrpcService(GreeterGrpc.class)
public class HelloGrpcServerImpl extends GreeterGrpc.GreeterImplBase {


    @Override
    public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
//        super.sayHello(request, responseObserver);
        // TODO: 2020/6/20  业务逻辑实现 
        String message = "hello" + request.getName();
        HelloReply.Builder helloReplyOrBuilder = HelloReply.newBuilder().setMessage(message);
        responseObserver.onNext(helloReplyOrBuilder.build());
        responseObserver.onCompleted();
        log.info("return :" + message);
    }
}
